package previous.Test_0326;

import java.util.Scanner;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Bridge_Blue {
    //最优分组
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n=scan.nextInt();
        double p=scan.nextDouble();
        double min=Double.MAX_VALUE;
        int mink=Integer.MAX_VALUE;
        for(int k=n;k>=1;k--) {
            if(n%k!=0) continue;
            double in=Math.pow(1-p, k);
            double avg=(double)n/k*(1+k*(1-in));
            if(k==1) avg=n;
            if(avg<=min) {
                min=avg;
                mink=k;
            }
        }
        System.out.println(mink);
        scan.close();
    }
}
